package com.lyy.king.common.rpc.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

/**
 * @ClassDescription:
 * @JdkVersion: 1.8
 * @Author: cdx
 * @Created: 2024/1/6 15:42
 */
@Configuration
public class DobboConfig {
    @Value("${spring.application.name}")
    private String appName;
    /**
     * dubbo协议名
     */
    @Value("${dubbo.protocol.name}")
    private String protocolName;

    /**
     * 协议端口
     */
    @Value("${dubbo.protocol.port}")
    private Integer protocolPort;
    /**
     * dubbo注册地址
     */
    @Value("${dubbo.registry.address}")
    private String registryAddress;

    @Value("${dubbo.registry.namespace}")
    private String registerNamespace;
    /**
     * 配置
     */
    private Map<String, String> parameters = new HashMap<>();

    @PostConstruct
    public void init() {
        parameters = new HashMap<>();
        parameters.put("namespace", registerNamespace);
    }

    public DobboConfig() {
    }

    public String getProtocolName() {
        return protocolName;
    }

    public void setProtocolName(String protocolName) {
        this.protocolName = protocolName;
    }

    public Integer getProtocolPort() {
        return protocolPort;
    }

    public void setProtocolPort(Integer protocolPort) {
        this.protocolPort = protocolPort;
    }

    public String getRegistryAddress() {
        return registryAddress;
    }

    public void setRegistryAddress(String registryAddress) {
        this.registryAddress = registryAddress;
    }

    public Map<String, String> getParameters() {
        return parameters;
    }

    public void setParameters(Map<String, String> parameters) {
        this.parameters = parameters;
    }

    public String getAppName() {
        return appName;
    }

    public void setAppName(String appName) {
        this.appName = appName;
    }

    public String getRegisterNamespace() {
        return registerNamespace;
    }

    public void setRegisterNamespace(String registerNamespace) {
        this.registerNamespace = registerNamespace;
    }
}
